// $Id$
// vim:ft=javascript

ARG_WITH("opencv", "for opencv support", "no");

// Otherwise, use ARG_ENABLE
// ARG_ENABLE("opencv", "enable opencv support", "no");


//当使用--with-opencv或--enable-opencv的时候PHP_OPENCV为yes，否则为no
if (PHP_OPENCV != "no") {
    ADD_FLAG("CFLAGS_OPENCV", "/EHcs");
    ADD_FLAG("CFLAGS_OPENCV", "/D _ALLOW_KEYWORD_MACROS");
    ADD_FLAG("CFLAGS_OPENCV", "/D __STDC_LIMIT_MACROS");

    //检查opencv链接库，如果存在返回路径
    CHECK_LIB("opencv_world400d.lib;opencv_world400.lib", "opencv","D:\\opencv\\build\\x64\\vc15\\lib");
    CHECK_HEADER_ADD_INCLUDE("opencv2\\opencv.hpp", "CFLAGS_OPENCV", "D:\\opencv\\build\\include");

    opencv_source_file="opencv.cc \
                opencv_exception.cc \
                source\\opencv2\\core\\hal\\opencv_interface.cc \
                source\\opencv2\\core\\opencv_base.cc \
                source\\opencv2\\core\\opencv_cvdef.cc \
                source\\opencv2\\core\\opencv_type.cc \
                source\\opencv2\\core\\opencv_utility.cc \
                source\\opencv2\\core\\opencv_persistence.cc \
                source\\opencv2\\core\\opencv_mat.cc \
                source\\opencv2\\face\\opencv_facerec.cc \
                source\\opencv2\\opencv_face.cc \
                source\\opencv2\\opencv_core.cc \
                source\\opencv2\\opencv_highgui.cc \
                source\\opencv2\\opencv_imgcodecs.cc \
                source\\opencv2\\opencv_imgproc.cc \
                source\\opencv2\\opencv_ml.cc \
                source\\opencv2\\opencv_objdetect.cc \
                source\\opencv2\\opencv_videoio.cc"


    EXTENSION("opencv", opencv_source_file,"yes");

    //使用ADD_SOURCES方式也可以
    //ADD_SOURCES(configure_module_dirname + "/source/opencv2/core/hal","opencv_interface.cc","opencv");
    //ADD_SOURCES(configure_module_dirname + "/source/opencv2/core","opencv_base.cc opencv_cvdef.cc","opencv");
    //ADD_SOURCES(configure_module_dirname + "/source/opencv2/core","opencv_base.cc opencv_cvdef.cc opencv_mat.cc opencv_persistence.cc \
    //opencv_type.cc opencv_utility.cc");
    //ADD_SOURCES(configure_module_dirname + "/source/opencv2/face","opencv_facerec.cc");
    //ADD_SOURCES(configure_module_dirname + "/source/opencv2","opencv_core.cc opencv_face.cc opencv_highgui.cc opencv_imgcodecs.cc \
    //opencv_imgproc.cc opencv_ml.cc opencv_objdetect.cc opencv_videoio.cc");

    //防止编译链接问题
    ADD_FLAG("CFLAGS_OPENCV", "/D ZEND_WIN32_KEEP_INLINE=1 /U ZEND_WIN32_FORCE_INLINE");


}


